using System;
using System.Collections.Generic;
using System.Text;

namespace Deepcode.Flux.Core.Codons.Asset
{
	/// <summary>
	/// Represents an ownership context when building
	/// AssetActionButtons from the addin tree.
	/// </summary>
	public class AssetActionContext
	{
		private System.Web.UI.Page	_Page		= null;
		private string				_Path		= "";
		private string				_Filename	= "";
		private AssetActionUse		_State		= AssetActionUse.FILE;
		private string				_Extension	= "";

		public System.Web.UI.Page Page { get { return _Page; } }
		public string Path { get { return _Path; } }
		public string Filename { get { return _Filename; } }
		public AssetActionUse State { get { return _State; } }
		public string Extension { get { return _Extension; } }

		public AssetActionContext(System.Web.UI.Page OwnerPage, string SelectedPath, string SelectedFile)
		{
			_Page		= OwnerPage;
			_Path		= SelectedPath;
			_Filename	= SelectedFile;

			_Extension	= System.IO.Path.GetExtension(_Filename).ToUpper();
			_State		= AssetActionUse.FILE;
			if (_Filename == "") _State = AssetActionUse.FOLDER;
			if ((_Filename == "") && (_Path == "~/assets")) _State = AssetActionUse.ROOT;
		}
	}
}
